/*
 * @Author: zengwj
 * @Date: 2022-08-08 16:59:08
 * @LastEditors: zengwj
 * @LastEditTime: 2022-08-09 11:05:14
 * @Description:
 */
import { proxy } from './utils.js'
import observe from './observe.js'
export default function initData(vm) {
	let { data } = vm.$options
	if (!data) {
		vm._data = {}
	} else {
		vm._data = typeof data === 'function' ? data() : data
	}
	// 将data 属性代理到vue实例上去，即通过this.xx访问
	for (let key in vm._data) {
		proxy(vm, '_data', key)
	}

	// 为数据设置响应式
	observe(vm._data)
}
